#include <bits/stdc++.h>

using namespace std;

#define in read()
#define vec vector <int>
#define pb push_back
#define debug(...) //fprintf(stderr,__VA_ARGS__)

typedef long long ll;

const int MAXN = 6e5+10;
const int inf = 0x3f3f3f3f;

ll tr[MAXN];
int n,m,k,o[MAXN],p[MAXN],s[MAXN],l[MAXN],r[MAXN],a[MAXN],ans[MAXN],lts[MAXN],rts[MAXN];
vec sp[MAXN];

void add(int x,int y){for(;x <= 2 * m + 2;x+=x&-x)tr[x]+=y;}

ll query(int x){ll res = 0;for(;x;x-=x&-x)res+=tr[x];return res;}

int read(){
	int x = 0,sgn = 1;char ch = getchar();
	for(;!isdigit(ch);ch = getchar()) if(ch == '-') sgn = -1;
	for(;isdigit(ch);ch = getchar()) x = (x<<1) + (x<<3) + (ch ^ 48);
	return x * sgn;
}

void solve(int sl,int sr,int lval,int rval){
	if(sl > sr) return;
	if(lval == rval){
		for(int i = sl;i <= sr;i++) ans[s[i]] = lval;
		return;
	}
	int mid = (lval + rval) >> 1;
	for(int i = lval;i <= mid;i++){
		add(l[i],a[i]),add(r[i] + 1,-a[i]);
	}
	int lnum = 0,rnum = 0;
	for(int i = sl;i <= sr;i++){
		int num = s[i];
		ll tot = 0;
		for(int j = 0;j < sp[num].size();j++){
			tot += query(sp[num][j]) + query(sp[num][j] + m) ;
			if(tot >= p[num]) break;
		}
		if(tot >= p[num]) lts[++lnum] = num;
		else rts[++rnum] = num,p[num] -= tot;
	}
	for(int i = lval;i <= mid;i++){
		add(l[i],-a[i]),add(r[i] + 1,a[i]);
	}
	for(int i = 1;i <= lnum;i++) s[sl + i - 1] = lts[i];
	for(int i = 1;i <= rnum;i++) s[sl + lnum + i - 1] = rts[i];
	solve(sl,sl + lnum-1,lval,mid);	solve(sl + lnum,sr,mid+1,rval);
}

int main (){
	n = in,m = in;
	for(int i = 1;i <= m;i++) o[i] = in,sp[o[i]].pb(i);
	for(int i = 1;i <= n;i++) p[i] = in;
	k = in;
	for(int i = 1;i <= k;i++) {
		l[i] = in,r[i] = in,a[i] = in;
		if(l[i] > r[i]) r[i] += m;
	}
	l[k+1] = 1,r[k+1] = m,a[k+1] = inf;
	for(int i = 1;i <= n;i++) s[i] = i;
	solve(1,n,1,k+1);
	for(int i = 1;i <= n;i++)
		if(ans[i] == k + 1) printf("NIE\n");
		else printf("%d\n",ans[i]);
	return 0;
}
